<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>循环输出数组的值</title>
    <script>
        let arr=[1,2,3,4,5,6];
        let num=0;
        let i=0;
        while (i<arr.length){
            alert("arr"+[i]+"="+(i+1))//输出数组的值
            num=num+arr[i];
            i++;
        }
        alert("arr的和="+num)//输出和
        alert("arr的平均值="+(num/arr.length).toFixed(2))//输出平均值.toFixed(2);
    </script>
</head>
<body>

</body>
</html>